home *** CD-ROM | disk | FTP | other *** search
/ Aminet 7 / Aminet 7 - August 1995.iso / Aminet / text / hyper / ADtoHT2_1.lha / Source.lha / MyLib.lha / string / strtok.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-05  |  404 b   |  34 lines

  1. #include <string.h>
  2.  
  3. /************************************************************************/
  4.  
  5. #undef strtok
  6.  
  7. char *strtok(char *s1, const char *s2)
  8.  
  9. {
  10.   static char *t;
  11.  
  12.   if (s1!=NULL)
  13.     {
  14.       t=s1;
  15.     }
  16.   else
  17.     {
  18.       s1=t;
  19.     }
  20.   s1+=strspn(s1,s2);
  21.   if (*s1=='\0')
  22.     {
  23.       return NULL;
  24.     }
  25.   t=s1;
  26.   t+=strcspn(s1,s2);
  27.   if(*t!='\0')
  28.     {
  29.       *t++='\0';
  30.     }
  31.   return s1;
  32. }
  33.   
  34.